package com.longtop.perform.jk.service;

import java.util.List;

import com.longtop.framework.base.BaseService;
import com.longtop.framework.common.QueryConditions;
import com.longtop.framework.common.QueryResult;
import com.longtop.framework.util.StringUtil;

public class DsCustService extends BaseService {

	public static final String BEAN_ID = "dsCustService";


	/**
	 * 依据条件，读取代码类别列表
	 * 
	 * @param value
	 *            查询的条件
	 * @param offset
	 *            查询结果的起始记录。
	 * @param size
	 *            查询结果的最大行数。如果不需要，则设置为-1
	 * @return
	 */
	public QueryResult loadCust(QueryConditions queryConditions, int pageNo, int pageSize) {
		String hql = "from DsCust";
		String orderBy = "custId asc";
		String[] propertyNames = null;
		String[] operators = null;
		Object[] values = null;

		if (queryConditions != null) {
			propertyNames = StringUtil.listToStrArray(queryConditions.getPropertyNames());
			operators = StringUtil.listToStrArray(queryConditions.getOperators());
			List valuesList = queryConditions.getValues();

			if (valuesList != null || valuesList.size() > 0)
				values = valuesList.toArray();
		}

		int offset = (pageNo - 1) * pageSize;

		// 执行查询
		Object[] result = this.query(hql, propertyNames, operators, values, offset, pageSize, true, orderBy, null, null);

		return new QueryResult((List) result[0], result[1] != null ? ((Integer) result[1]).intValue() : 0);
	}

}